package com.cskaoyan.service.set;

import com.cskaoyan.bean.bo.configbo.MallConfigBo;
import com.cskaoyan.bean.vo.set.ExpressConfigVo;
import com.cskaoyan.bean.vo.set.OrderConfigVo;
import com.cskaoyan.bean.vo.set.WxConfigVo;
import com.cskaoyan.mapper.MarketSystemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description:todo 配置管理service
 * @Author:todo wang xv
 * @Date:todo 2022/11/21
 */
@Service
public class AdminConfigServiceImpl implements AdminConfigService {
    @Autowired
    MarketSystemMapper marketSystemMapper;


    /**
     * @Description:todo 用于商场配置管理
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @Override
    public void mallConfig(MallConfigBo mallConfigBo) {
        String address = "market_mall_address";
        String latitude = "market_mall_latitude";
        String longitude = "market_mall_longitude";
        String mallName = "market_mall_name";
        String mallPhone = "market_mall_phone";
        String mallQQ = "market_mall_qq";

        marketSystemMapper.updateConfig(address, mallConfigBo.getMarket_mall_address());
        marketSystemMapper.updateConfig(latitude, mallConfigBo.getMarket_mall_latitude());
        marketSystemMapper.updateConfig(longitude, mallConfigBo.getMarket_mall_longitude());
        marketSystemMapper.updateConfig(mallName, mallConfigBo.getMarket_mall_name());
        marketSystemMapper.updateConfig(mallPhone, mallConfigBo.getMarket_mall_phone());
        marketSystemMapper.updateConfig(mallQQ, mallConfigBo.getMarket_mall_qq());

    }

    /**
     * @Description:todo 商场配置时回显数据
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @Override
    public MallConfigBo mallConfigShow() {
        String address = "market_mall_address";
        String latitude = "market_mall_latitude";
        String longitude = "market_mall_longitude";
        String mallName = "market_mall_name";
        String mallPhone = "market_mall_phone";
        String mallQQ = "market_mall_qq";

        MallConfigBo mallConfigBo = new MallConfigBo();
        mallConfigBo.setMarket_mall_address(marketSystemMapper.selectValueByName(address));
        mallConfigBo.setMarket_mall_latitude(marketSystemMapper.selectValueByName(latitude));
        mallConfigBo.setMarket_mall_longitude(marketSystemMapper.selectValueByName(longitude));
        mallConfigBo.setMarket_mall_name(marketSystemMapper.selectValueByName(mallName));
        mallConfigBo.setMarket_mall_phone(marketSystemMapper.selectValueByName(mallPhone));
        mallConfigBo.setMarket_mall_qq(marketSystemMapper.selectValueByName(mallQQ));
        return mallConfigBo;
    }

    /**
     * @Description:todo 显示运费
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @Override
    public ExpressConfigVo expressConfigShow() {
        String minExpress = "market_express_freight_min";
        String valueExpress = "market_express_freight_value";
        ExpressConfigVo expressConfigVo = new ExpressConfigVo();
        expressConfigVo.setMarket_express_freight_min(marketSystemMapper.selectValueByName(minExpress));
        expressConfigVo.setMarket_express_freight_value(marketSystemMapper.selectValueByName(valueExpress));
        return expressConfigVo;
    }

    /**
     * @Description:todo 编辑运费配置
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @Override
    public void expressConfig(ExpressConfigVo expressConfigVo) {
        String minExpress = "market_express_freight_min";
        String valueExpress = "market_express_freight_value";

        marketSystemMapper.updateConfig(minExpress, expressConfigVo.getMarket_express_freight_min());
        marketSystemMapper.updateConfig(valueExpress, expressConfigVo.getMarket_express_freight_value());
    }

    /**
     * @Description:todo 显示订单的配置
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @Override
    public OrderConfigVo orderConfigShow() {
        String unConfirm = "market_order_unconfirm";
        String unPaid = "market_order_unpaid";
        String comment = "market_order_comment";
        OrderConfigVo orderConfigVo = new OrderConfigVo();
        orderConfigVo.setMarket_order_unconfirm(marketSystemMapper.selectValueByName(unConfirm));
        orderConfigVo.setMarket_order_unpaid(marketSystemMapper.selectValueByName(unPaid));
        orderConfigVo.setMarket_order_comment(marketSystemMapper.selectValueByName(comment));
        return orderConfigVo;
    }

    /**
     * @Description:todo 订单配置的编辑
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @Override
    public void orderConfig(OrderConfigVo orderConfigVo) {
        String unConfirm = "market_order_unconfirm";
        String unPaid = "market_order_unpaid";
        String comment = "market_order_comment";
        marketSystemMapper.updateConfig(unConfirm, orderConfigVo.getMarket_order_unconfirm());
        marketSystemMapper.updateConfig(unPaid, orderConfigVo.getMarket_order_unpaid());
        marketSystemMapper.updateConfig(comment, orderConfigVo.getMarket_order_comment());
    }

    /**
     * @Description:todo 小程序配置的显示
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @Override
    public WxConfigVo wxConfigShow() {
        String indexNew = "market_wx_index_new";
        String indexTopic = "market_wx_index_topic";
        String share = "market_wx_share";
        String indexBrand = "market_wx_index_brand";
        String catlogGoods = "market_wx_catlog_goods";
        String catlogList = "market_wx_catlog_list";
        String indexHot = "market_wx_index_hot";
        WxConfigVo wxConfigVo = new WxConfigVo();
        wxConfigVo.setMarket_wx_index_new(marketSystemMapper.selectValueByName(indexNew));
        wxConfigVo.setMarket_wx_index_topic(marketSystemMapper.selectValueByName(indexTopic));
        wxConfigVo.setMarket_wx_share(marketSystemMapper.selectValueByName(share));
        wxConfigVo.setMarket_wx_index_brand(marketSystemMapper.selectValueByName(indexBrand));
        wxConfigVo.setMarket_wx_catlog_goods(marketSystemMapper.selectValueByName(catlogGoods));
        wxConfigVo.setMarket_wx_catlog_list(marketSystemMapper.selectValueByName(catlogList));
        wxConfigVo.setMarket_wx_index_hot(marketSystemMapper.selectValueByName(indexHot));
        return wxConfigVo;
    }

    /**
     * @Description:todo 小程序配置的修改
     * @Author:todo wang xv
     * @Date:todo 2022/11/21
     */
    @Override
    public void wxConfig(WxConfigVo wxConfigVo) {
        String indexNew = "market_wx_index_new";
        String indexTopic = "market_wx_index_topic";
        String share = "market_wx_share";
        String indexBrand = "market_wx_index_brand";
        String catlogGoods = "market_wx_catlog_goods";
        String catlogList = "market_wx_catlog_list";
        String indexHot = "market_wx_index_hot";

        marketSystemMapper.updateConfig(indexNew, wxConfigVo.getMarket_wx_index_new());
        marketSystemMapper.updateConfig(indexTopic, wxConfigVo.getMarket_wx_index_topic());
        marketSystemMapper.updateConfig(share, wxConfigVo.getMarket_wx_share());
        marketSystemMapper.updateConfig(indexBrand, wxConfigVo.getMarket_wx_index_brand());
        marketSystemMapper.updateConfig(catlogGoods, wxConfigVo.getMarket_wx_catlog_goods());
        marketSystemMapper.updateConfig(catlogList, wxConfigVo.getMarket_wx_catlog_list());
        marketSystemMapper.updateConfig(indexHot, wxConfigVo.getMarket_wx_index_hot());
    }
}
